<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>018-面向对象高级-继承一.html</title>
</head>
<body>
	
</body>
<script>
	function Person(name,age){
		this.name = name;
		this.age = age;
	}
	Person.prototype.showName = function(){
		console.log("I am "+ this.name);
	}
	Person.prototype.showAge = function(){
		console.log("I am "+ this.age + "years old");
	}
	function Student(name,age,major){
		// this.name = name;
		// this.age = age;
		// this.major = major;
		//属性继承
		Person.call(this,name,age);
		this.major = major;
	}
	/*
	Student.prototype.showName = function(){
		console.log("I am"+this.name);
	}
	Student.prototype.showAge = function(){
		console.log("I am"+this.age + "years old");
	}
	Student.prototype.showMajor = function(){
		console.log("I am come from"+this.major);
	}
	*/
	Student.prototype = Person.prototype;
	Student.prototype.showMajor = function(){
		console.log("I am from "+ this.major);
	}
	var s1 = new Student("chris",18,"computer");
	s1.showName();
	s1.showAge();
	s1.showMajor();


	var p1 = new Person("vincent",24);
	p1.showName();
	p1.showMajor();
	p1.showAge();
</script>
</html>